home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1994 March / Internet Info CD-ROM (Walnut Creek) (March 1994).iso / networking / mail / mm / patch.02 < prev    next >
Encoding:
Text File  |  1991-01-03  |  7.1 KB  |  272 lines

  1. Patch number: 2
  2. MM Version: 0.90
  3. Date: Fri Jan  4 17:20:06 1991
  4. File: newmail.c
  5.  
  6.  
  7. Description:
  8.  
  9. if mail_directory is unset, can't read in new mail, unless /.mm-newmail
  10. is writable.
  11.  
  12.  
  13. Fix:
  14.  
  15. Check for blank mail_directory, and use HOME instead.  Also, some
  16. other assorted cleanup in new_mail().
  17.  
  18.  
  19. Patch:
  20.  
  21. *** /tmp/,RCSt1013017    Fri Jan  4 17:18:15 1991
  22. --- newmail.c    Fri Jan  4 17:17:17 1991
  23. ***************
  24. *** 35,45 ****
  25.       static msgvec *nf;
  26.       msgvec *nmf;
  27.       int type;
  28. -     keylist i;
  29.       static struct stat mailbuf;
  30.       struct stat oldbuf, sbuf;
  31.       extern int continuous_check;
  32.       int result = true;
  33.   
  34.       /* if they're busy and don't want to be bothered, don't interrupt */
  35.       if (quiet && !continuous_check && mode != MM_TOP_LEVEL)
  36. --- 35,46 ----
  37.       static msgvec *nf;
  38.       msgvec *nmf;
  39.       int type;
  40.       static struct stat mailbuf;
  41.       struct stat oldbuf, sbuf;
  42.       extern int continuous_check;
  43.       int result = true;
  44. +     string new_mail_filename;
  45. +     int getting_mail;
  46.   
  47.       /* if they're busy and don't want to be bothered, don't interrupt */
  48.       if (quiet && !continuous_check && mode != MM_TOP_LEVEL)
  49. ***************
  50. *** 66,72 ****
  51.           in_here = false;
  52.       }
  53.       }
  54. !     if ((cf != NULL) && !(cf->flags & MF_RDONLY) && (cf->flags & MF_MAILBOX)) {
  55.       nmf = (msgvec *) malloc(sizeof(msgvec));
  56.       if (!nmf)
  57.           return;            /* XXX */
  58. --- 67,82 ----
  59.           in_here = false;
  60.       }
  61.       }
  62. !     /* use mail_directory if defined and not "." ("." hard to find later) */
  63. !     sprintf(new_mail_filename,"%s/%s", 
  64. !         (strcmp(".",mail_directory) && mail_directory[0] != NULL) ?
  65. !         mail_directory : HOME, tempfile);
  66. !     getting_mail = ((cf != NULL) && !(cf->flags & MF_RDONLY) && 
  67. !             (cf->flags & MF_MAILBOX)); /* getting or just looking? */
  68. !     
  69. !     /* check for leftover (orphaned) .mm-newmail */
  70. !     if (getting_mail) {
  71.       nmf = (msgvec *) malloc(sizeof(msgvec));
  72.       if (!nmf)
  73.           return;            /* XXX */
  74. ***************
  75. *** 73,80 ****
  76.       
  77.       bzero (nmf, sizeof (msgvec));
  78.   
  79. !     sprintf(nmf->filename,"%s/%s", 
  80. !         strcmp(".",mail_directory)?mail_directory:HOME, tempfile);
  81.       if (stat(nmf->filename,&sbuf) == 0) {
  82.           switch (mail_probe (nmf->filename,&type)) { /* can we read this? */
  83.           case PR_NAME:
  84. --- 83,89 ----
  85.       
  86.       bzero (nmf, sizeof (msgvec));
  87.   
  88. !     strcpy(nmf->filename, new_mail_filename);
  89.       if (stat(nmf->filename,&sbuf) == 0) {
  90.           switch (mail_probe (nmf->filename,&type)) { /* can we read this? */
  91.           case PR_NAME:
  92. ***************
  93. *** 109,114 ****
  94. --- 118,125 ----
  95.       }
  96.       }
  97.   
  98. +     /* check for (new) incoming mail */
  99.       if (incoming_mail == NULL) {
  100.       incoming_mail = (keylist) malloc(2 * sizeof(char *));
  101.       incoming_mail[0] = malloc(strlen(user_name) + 
  102. ***************
  103. *** 116,147 ****
  104.       sprintf(incoming_mail[0], "%s/%s", SPOOL_DIRECTORY, user_name);
  105.       incoming_mail[1] = NULL;
  106.       }
  107. !     for(i = incoming_mail; i && *i; i++) {
  108. !     switch (mail_probe (*i, &type))    { /* can we read this? */
  109.       case PR_NAME:
  110.           if (!quiet)
  111. !         cmxprintf("?Badly formed filename: %s\n", *i);
  112.           continue;
  113.       case PR_NOEX:
  114.           continue;
  115.       case PR_PERM:
  116.           if (!quiet)
  117. !         cmxprintf("?Cannot read file: %s\n", *i);
  118.           continue;
  119.       case PR_EMPTY:
  120.           continue;
  121.       case PR_NOTOK:
  122.           if (!quiet)
  123. !         cmxprintf("?File is damaged or in unknown format: %s\n", *i);
  124.           continue;
  125.       }
  126.   
  127. !     if (stat(*i,&sbuf) < 0)
  128. !         continue;
  129. !     if ((cf == NULL) || (cf->flags & MF_RDONLY) || 
  130. !         !(cf->flags & MF_MAILBOX)) {
  131.           if (sbuf.st_mtime > oldbuf.st_mtime || !quiet) {
  132. !         printf("You have new mail in %s.\n", *i);
  133.           if (sbuf.st_mtime > mailbuf.st_mtime)
  134.               mailbuf = sbuf;
  135.           sawmail = true;
  136. --- 127,157 ----
  137.       sprintf(incoming_mail[0], "%s/%s", SPOOL_DIRECTORY, user_name);
  138.       incoming_mail[1] = NULL;
  139.       }
  140. !     for(im = incoming_mail; im && *im; im++) { /* loop over inboxes */
  141. !     if (stat(*im,&sbuf) < 0)
  142. !         continue;
  143. !     switch (mail_probe (*im, &type))    { /* can we read this? */
  144.       case PR_NAME:
  145.           if (!quiet)
  146. !         cmxprintf("?Badly formed filename: %s\n", *im);
  147.           continue;
  148.       case PR_NOEX:
  149.           continue;
  150.       case PR_PERM:
  151.           if (!quiet)
  152. !         cmxprintf("?Cannot read file: %s\n", *im);
  153.           continue;
  154.       case PR_EMPTY:
  155.           continue;
  156.       case PR_NOTOK:
  157.           if (!quiet)
  158. !         cmxprintf("?File is damaged or in unknown format: %s\n", *im);
  159.           continue;
  160.       }
  161.   
  162. !     if (!getting_mail) {
  163.           if (sbuf.st_mtime > oldbuf.st_mtime || !quiet) {
  164. !         printf("You have new mail in %s.\n", *im);
  165.           if (sbuf.st_mtime > mailbuf.st_mtime)
  166.               mailbuf = sbuf;
  167.           sawmail = true;
  168. ***************
  169. *** 152,169 ****
  170.       nf = (msgvec *) malloc(sizeof(msgvec));
  171.       bzero(nf,sizeof(msgvec));
  172.       nf->type = type;
  173. !     if (same_file (cf->filename, nf->filename))
  174. !         cmxprintf ("\
  175. ! ?Cannot read incoming mail file %s that is primary mail file\n", *i);
  176. !     else {
  177. !         if (move_mail (*i, strcmp(mail_directory,".")?mail_directory:HOME,
  178. !         tempfile, quiet) != 0)
  179. !         nmreturn (result);
  180. !         sprintf(nf->filename,"%s/%s", 
  181. !             strcmp(mail_directory,".")?mail_directory:HOME, tempfile);
  182. !         if (!fetchmail(nf,*i))
  183. !         return(true);
  184.       }
  185.       }
  186.       result = sawmail || gotmail;
  187.       nmreturn (result);
  188. --- 162,187 ----
  189.       nf = (msgvec *) malloc(sizeof(msgvec));
  190.       bzero(nf,sizeof(msgvec));
  191.       nf->type = type;
  192. !     strcpy (nf->filename, new_mail_filename);
  193. !     if (same_file (cf->filename, new_mail_filename)) {
  194. !         cmxprintf ("?Primary mail file cannot be %s.\n",
  195. !                new_mail_filename);
  196. !         continue;
  197.       }
  198. +     if (same_file (new_mail_filename, *im)) {
  199. +         cmxprintf ("?Incoming mail file cannot be %s.\n",
  200. +                new_mail_filename);
  201. +         continue;
  202. +     }
  203. +     if (same_file (cf->filename, *im)) {
  204. +         cmxprintf ("?Incoming mail file cannot be primary mail file %s.\n",
  205. +                cf->filename);
  206. +         continue;
  207. +     }
  208. +     if (move_mail (*im, new_mail_filename, quiet) != 0)
  209. +         nmreturn (result);
  210. +     if (!fetchmail(nf,*im))
  211. +         return(true);
  212.       }
  213.       result = sawmail || gotmail;
  214.       nmreturn (result);
  215. ***************
  216. *** 276,294 ****
  217.       return(true);
  218.   }
  219.   
  220. ! move_mail(from, todir, tofile, quiet)
  221. ! char *from, *todir, *tofile;
  222.   int quiet;
  223.   {
  224.       int ret;
  225.       extern string movemail_path;
  226.       char *movemail_argv[4];
  227. -     char buf[MAXPATHLEN];
  228.       
  229.       movemail_argv[0] = movemail_path;
  230.       movemail_argv[1] = from;
  231. !     sprintf(buf,"%s/%s", todir, tofile);
  232. !     movemail_argv[2] = buf;
  233.       movemail_argv[3] = nil;
  234.   
  235.       fix_signals_for_fork (true);
  236. --- 294,310 ----
  237.       return(true);
  238.   }
  239.   
  240. ! move_mail(from, tofile, quiet)
  241. ! char *from, *tofile;
  242.   int quiet;
  243.   {
  244.       int ret;
  245.       extern string movemail_path;
  246.       char *movemail_argv[4];
  247.       
  248.       movemail_argv[0] = movemail_path;
  249.       movemail_argv[1] = from;
  250. !     movemail_argv[2] = tofile;
  251.       movemail_argv[3] = nil;
  252.   
  253.       fix_signals_for_fork (true);
  254.  
  255.  
  256.  
  257. *** /tmp/,RCSt1029082    Fri Jan  4 17:18:32 1991
  258. --- mm-patchlevel.h    Fri Jan  4 17:17:41 1991
  259. ***************
  260. *** 10,13 ****
  261.    * release.  Don't forget to send diffs for this file in the patch file.
  262.    */
  263.   
  264. ! #define MM_PATCH 1
  265. --- 10,13 ----
  266.    * release.  Don't forget to send diffs for this file in the patch file.
  267.    */
  268.   
  269. ! #define MM_PATCH 2
  270.